<template>
  <a-modal :visible="myVisible" @ok="handleOk" @cancel="handleCancel">
    <template #title> 选择人员 </template>
    <a-space direction="vertical" size="large">
      <a-radio-group @change="change">
        <a-radio
          v-for="item in humenList"
          :key="item.userId"
          :value="item.userId"
        >
          <span v-for="i in item.positionDetailData" :key="i.id">
            <template v-if="i.code === 'C62B8DC31189847E0972B5D8F721404B1'">
              {{ i.value }}
            </template>
          </span>
        </a-radio>
      </a-radio-group>
    </a-space>
  </a-modal>
</template>
<script setup lang="ts">
import { GetHumanRosterList } from '@/apis/management/human/humanRoster';
const props = withDefaults(
  defineProps<{
    visible: boolean;
    participantInfos?: any;
  }>(),
  {
    visible: false
  }
);
const myVisible = computed({
  get: () => props.visible,
  set: () => emit('update:visible')
});
const emit = defineEmits(['update:visible', 'update:participantInfos']);

const close = () => {
  emit('update:visible', false);
};
const handleClick = () => {
  close();
};
const handleOk = () => {
  // emit('update:participantInfos', selected.value);
  // close();
  console.log('sdf', selected.value);
};
const handleCancel = () => {
  close();
};
const selected = ref<any>([]);
const change = (e: any) => {
  console.log(e);

  // const user = humenList.find((item) => {
  //   //
  // });
  // const user = humenList.find((item) => item.objId === e);
  // selected.value = [user];
};
const humenList = ref<any>([]);
const humenList2 = ref<any>([]); //id和名称数组
const getHumenList = async () => {
  const res = await GetHumanRosterList({
    page: 0,
    size: 10,
    ctlCode: 'C62B8DC31189847E0972B5D8F721404B1'
  });
  humenList.value = res.content || [];
};
watch(
  () => props.visible,
  (val) => {
    val && getHumenList();
  }
);
</script>
